package org.zhs.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @Author: zhs
 * @Date: 2021/6/24 11:06
 * @Description:
 *
 * 查询索引
 */
public class ESTest_Index_Search {
    public static void main(String[] args) throws IOException {
        //创建ES客户端
        RestHighLevelClient rsClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",9200,"http")));


        //查询索引
        GetIndexRequest request = new GetIndexRequest("user");
        GetIndexResponse response = rsClient.indices().get(request, RequestOptions.DEFAULT);

        System.out.println(response.getAliases());
        System.out.println(response.getMappings());
        System.out.println(response.getSettings());


        //关闭客户端
        rsClient.close();
    }
}
